﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using GSdk.Net.Lglcd;

namespace GSdk.Net.HelloWorld
{
    class Program
    {
        // We need an image to update, a 320x240 Format32bppArgb bitmap is required to update a Qvga device
        static Bitmap image = new Bitmap(320, 240, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
        static void Main(string[] args)
        {
            Console.WriteLine("Begin");
            // Perform some graphic operations
            using (Graphics g = Graphics.FromImage(image))
            {
                g.FillRectangle(Brushes.Red, new Rectangle(0, 0, image.Width, image.Height));
                g.DrawString("Hello World", SystemFonts.DefaultFont, Brushes.White, new PointF(0f, 0f));
            }

            // This is quite horrible to read: we are first assignig some values to our Applet, so first squared brackets don't belong to "using" statement
            using (Applet app = new Applet() { Name = "Hello World", SupportedDevices = DeviceTypes.Qvga, Autostartable = false, })
            // This is where the using statement begins
            {
                // Connect the applet to Logitech gaming software
                app.Connect();
                // Update the image
                app.GetDevices<DefaultDeviceCollection>().Qvga.Update(image);
                Console.WriteLine("Press ENTER to continue...");
                Console.ReadLine();
                // Once the using statement ends, Dispose is colled on our Applet. It will automatically call Disconnect if required
            }

            Console.WriteLine("Press ENTER to close the application");
            Console.ReadLine();
        }
    }
}
